/**
 * Copyright 2008-2009. Chongqing Communications Industry Services Co.,Ltd Information Technology Branch. All rights
 * reserved. <a>http://www.cqcis.com</a>
 */
package com.firebird.base.test;

import java.util.Iterator;
import java.util.Map;

import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.persister.entity.EntityPersister;

/**
 * @author qiuxj
 * @date 2009-11-14
 */
public class BaseHibernateMappingTestCase extends BaseTestCase {

	  private SessionFactory sessionFactory;

	  public void testColumnMapping()
	    throws Exception
	  {
	    SessionFactory sf = this.sessionFactory;
	    Session session = sf.openSession();
	    try {
	      Map metadata = sf.getAllClassMetadata();
	      for (Iterator localIterator = metadata.values().iterator(); localIterator.hasNext(); ) { Object o = localIterator.next();
	        EntityPersister persister = (EntityPersister)o;
	        String className = persister.getEntityName();
	        this.log.debug("Trying select * from: " + className);
	        Query q = session.createQuery("from " + className + " c");
	        q.iterate();
	        this.log.debug("ok: " + className);
	      }
	    } finally {
	      session.close();
	    }
	  }

	  public SessionFactory getSessionFactory() {
	    return this.sessionFactory;
	  }

	  public void setSessionFactory(SessionFactory sessionFactory) {
	    this.sessionFactory = sessionFactory;
	  }
	
}
